import java.util.Arrays;

public class InsertSort {

    public static int[] generateRandomArray(int maxSize,int maxValue){
        int[] arr = new int[(int)((maxSize+1)*Math.random())];
        for(int i = 0;i<arr.length;i++){
            arr[i] = (int)((maxValue+1)*Math.random())-(int)(maxValue*Math.random());
        }
        return arr;
    }

    public static int[] copyArray(int[] arr){
        if(arr==null){
            return null;
        }
        int[] rus = new int[arr.length];
        for(int i = 0;i<arr.length;i++){
            rus[i] = arr[i];
        }
        return rus;
    }

    public static void selectionSort(int[] arr){
        for(int i = 1;i<arr.length;i++){
            for(int j = i;j>0&&arr[j]<arr[j-1];j--){
                int tem = arr[j];
                arr[j] = arr[j-1];
                arr[j-1] = tem;
            }
        }
    }
    public static void comparator(int[] arr){
        Arrays.sort(arr);
    }

    public static boolean isEqual(int[] arr1,int[] arr2){
        if((arr1==null&&arr2!=null)||(arr1!=null&&arr2==null)){
            return false;
        }
        if(arr1==null&&arr2==null){
            return true;
        }
        if(arr1.length!=arr2.length){
            return false;
        }
        for(int i = 0;i<arr1.length;i++){
            if(arr1[i]!=arr2[i]){
                return false;
            }
        }
        return true;
    }
    public static void printfArray(int[] arr){
        for(int i = 0;i<arr.length;i++){
            System.out.print(arr[i]+" ");
        }
        System.out.println();
    }

    public static void main(String[] args) {
        int textTime = 500000;
        int maxSize = 100;
        int maxValue = 100;
        boolean succeed = true;
        for(int i = 0;i<textTime;i++){
            int[] arr1 = generateRandomArray(maxSize,maxValue);
            int[] arr2 = copyArray(arr1);
            selectionSort(arr1);
            comparator(arr2);
            if(!isEqual(arr1,arr2)){
                succeed = false;
                printfArray(arr1);
                printfArray(arr2);
            }
        }
        System.out.println(succeed?"Nice":"Fucking fucked");

    }

    public static void main2(String[] args) {
        int[] arr = new int[]{9,8,7,6,5,4,3,2,1};
        for(int i = 1;i<arr.length;i++){
            for(int j = i;j>0&&arr[j]<arr[j-1];j--){
                int tem = arr[j];
                arr[j] = arr[j-1];
                arr[j-1] = tem;
            }
        }
        for(int i = 0;i<arr.length;i++){
            System.out.print(arr[i]);
        }
    }
}
